package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmWechatOrderMapper;
import cn.mcartoon.pojo.MmWechatOrder;
import cn.mcartoon.service.MmWechatOrderService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmWechatOrderServiceImpl implements MmWechatOrderService {

    @Autowired
    private MmWechatOrderMapper mmWechatOrderMapper;

    public MmWechatOrder getMmWechatOrderById(Long id){
        return mmWechatOrderMapper.getMmWechatOrderById(id);
    }

    public List<MmWechatOrder>	getMmWechatOrderListByMap(Map<String,Object> param){
        return mmWechatOrderMapper.getMmWechatOrderListByMap(param);
    }

    public Integer getMmWechatOrderCountByMap(Map<String,Object> param){
        return mmWechatOrderMapper.getMmWechatOrderCountByMap(param);
    }

    public Integer insertMmWechatOrder(MmWechatOrder mmWechatOrder){
            return mmWechatOrderMapper.insertMmWechatOrder(mmWechatOrder);
    }

    public Integer updateMmWechatOrder(MmWechatOrder mmWechatOrder){
        return mmWechatOrderMapper.updateMmWechatOrder(mmWechatOrder);
    }

    public Integer deleteMmWechatOrderById(Long id){
        return mmWechatOrderMapper.deleteMmWechatOrderById(id);
    }

    public Integer batchDeleteMmWechatOrder(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmWechatOrderMapper.batchDeleteMmWechatOrder(param);
    }

    public Page<MmWechatOrder> queryMmWechatOrderPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmWechatOrderMapper.getMmWechatOrderCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmWechatOrder> mmWechatOrderList = mmWechatOrderMapper.getMmWechatOrderListByMap(param);
        page.setList(mmWechatOrderList);
        return page;
     }


}
